package com.sun.springboot_mq.topic.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shkstart
 * @create 2021-10-24 20:17
 */
@Configuration
public class TopicRabbitMqConfig {
    final static String message = "topic.message";
    final static String messages = "topic.messages";
    @Bean
    public Queue queueMessage(){
        return new Queue(TopicRabbitMqConfig.message);
    }
    @Bean
    public Queue queueMessages(){
        return new Queue(TopicRabbitMqConfig.messages);
    }
    @Bean
    public Exchange exchange(){
        return new TopicExchange("exchange");
    }
    @Bean
    public Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange){
         return BindingBuilder.bind(queueMessage).to(exchange).with("topic.message");
    }
    @Bean
    public Binding bindingExchangeMessages(Queue queueMessages, TopicExchange exchange){
        return BindingBuilder.bind(queueMessages).to(exchange).with("topic.#");
    }

}
